package br.ufms.facom;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.io.Serializable;

public class Truco implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -679577004101317154L;
	
	
	List<String> cards;
	List<String> baralho;
	int turno=0;
	
	public Truco() {
		cards = new ArrayList<String>();
		cards.add("3p");
		cards.add("3c");
		cards.add("3e");
		cards.add("3o");
		cards.add("2p");
		cards.add("2c");
		cards.add("2e");
		cards.add("2o");
		cards.add("ap");
		cards.add("ac");
		cards.add("ae");
		cards.add("ao");
		cards.add("kp");
		cards.add("kc");
		cards.add("ke");
		cards.add("ko");
		cards.add("jp");
		cards.add("jc");
		cards.add("je");
		cards.add("jo");
		cards.add("qp");
		cards.add("qc");
		cards.add("qe");
		cards.add("qo");
		cards.add("7p");
		cards.add("7c");
		cards.add("7e");
		cards.add("7o");
		cards.add("6p");
		cards.add("6c");
		cards.add("6e");
		cards.add("6o");
		cards.add("5p");
		cards.add("5c");
		cards.add("5e");
		cards.add("5o");
		cards.add("4p");
		cards.add("4c");
		cards.add("4e");
		cards.add("4o");
		baralho = new ArrayList<String>();
		for ( int i =0 ; i < cards.size() ; i++)
			baralho.add(cards.get(i));
	}
	
	public void embaralha(){
		Collections.shuffle(baralho);
	}

	@Override
	public String toString() {
		return "Truco [cards=" + cards.toString() + "\nbaralho=" + baralho.toString() + ", \nturno="
				+ turno + "]";
	}

	public String getCartas() {
		String cartas = "";
		cartas += baralho.get(0)+ " "+baralho.get(1)+ " "+baralho.get(2)+ " "+baralho.get(3)+ " "+baralho.get(4)+ " "+baralho.get(5)+ " "+baralho.get(6);
		System.out.println("CARTAS:");
		System.out.println(cartas);
		return cartas;
	}
	
	public int procura(String carta){
		for ( int i = 0 ; i < cards.size() ; i++){
			if ( carta.contains(cards.get(i)))
				return i;
		}
		return cards.size();
	}

	public int getTurno() {
		return turno;
	}

	public void setTurno(int turno) {
		this.turno = turno;
	}
	
	
	
}
